import { Component, OnInit, Input } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
  selector: 'app-button-copy',
  templateUrl: './button-copy.component.html',
  styleUrls: ['./button-copy.component.scss']
})
export class ButtonCopyComponent implements OnInit {

  // 传入要复制文本
  @Input() text: any = '';

  // 是否可点击
  @Input() disabled: boolean = false;

  constructor(
    private message: NzMessageService
  ) { }

  ngOnInit() {
  }
  /**
    * 复制内容
  */
  onCopy() {
    let oInput = document.createElement('input');
    oInput.value = this.text;
    document.body.appendChild(oInput);
    oInput.select();
    document.execCommand('Copy');
    document.body.removeChild(oInput);
    this.message.success('复制成功')
  }

}
